package com.zlm.add;

import java.util.concurrent.CountDownLatch;

/**
 * @Author: 郑
 * 减法计数器
 */
public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);
        for (int i = 0; i < 6; i++) {
            new Thread(() ->{
                System.out.println(Thread.currentThread().getName()+"GO");
                countDownLatch.countDown();//数量减1
            },String.valueOf(i)).start();
        }
        countDownLatch.await();//等待计数器归零，向下执行
        System.out.println("close door");
    }
}
